home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 3.1
/
SGI EnlightenDSM 3.1.iso
/
DEC3240
/
COMMON.Z
/
COMMON
/
bin
/
set_nis_slave
< prev
next >
Wrap
Text File
|
1999-04-16
|
2KB
|
148 lines
#!/bin/sh
#
# Copyright (c) 1990-1999 Enlighten Software Solutions, Inc.
#
# Check arguments: <domain> <master> <start_at_boot> <client_also>
if [ $# -ne 4 ]
then
exit 1
fi
DOMAIN=$1
MASTER=$2
STARTATBOOT=$3
CLIENT=$4
# Initialize variables
TMP=/tmp/nissetup.slave.$$
HOSTS=/etc/hosts
RCCONF=/etc/rc.config
ECHO=/bin/echo
RCMGR=/usr/sbin/rcmgr
NISSETUP=/usr/sbin/nissetup
YPDIR=/var/yp
# Check if NIS is already configured
prev_conf=`$RCMGR get NIS_CONF`
# Check to make sure nissetup won't complain about
# system configuration
if [ \! -w "$RCCONF" ]
then
exit 2
fi
hname=`hostname`
if [ $? -ne 0 ]
then
exit 3
fi
if [ "$prev_conf" = "YES" ]
then
exit 4
fi
if [ \! -d "$YPDIR" ]
then
exit 5
fi
# Yes, we want to continue
$ECHO "C" > $TMP
# Press ENTER twice
$ECHO "\n" >> $TMP
# The host's NIS domain name
$ECHO $DOMAIN >> $TMP
# ... yes, this is the correct NIS domain name
$ECHO "y" >> $TMP
# This is going to be a NIS slave server
$ECHO "2" >> $TMP
# Copy the current maps from the master server
if [ -d "$YPDIR/$DOMAIN" ]
then
$ECHO "Y" >> $TMP
fi
# Yes, we want to continue
$ECHO "C" >> $TMP
$ECHO $MASTER >> $TMP
sed "s/#.*//" $HOSTS > $HOSTS.tmp
good=`egrep "[ ]$MASTER([ \.]|$)" $HOSTS.tmp`
if [ -n "$good" ]
then
short=`echo $hname | sed 's/\..*//'`
if [ "$MASTER" = "$hname" ] || [ "$MASTER" = "$short" ]
then
exit 6
fi
else
exit 7
fi
rm -rf $YPDIR/$DOMAIN
if [ $? -ne 0 ]
then
exit 8
fi
mkdir $YPDIR/$DOMAIN
if [ $? -ne 0 ]
then
exit 9
fi
rmdir $YPDIR/$DOMAIN
# Use the -s security option for ypbind
$ECHO "y" >> $TMP
# Use the -S security option for ypbind
$ECHO "y" >> $TMP
# Enter (just one) authorized server
$ECHO $MASTER >> $TMP
$ECHO "" >> $TMP
# Check to make sure the server name is a correct NIS server name
sed "s/#.*//" $HOSTS > $HOSTS.tmp
good=`egrep "[ ]$MASTER([ \.]|$)" $HOSTS.tmp`
if [ -n "$good" ]
then
short=`echo $hname | sed 's/\..*//'`
if [ "$MASTER" = "$hname" ] || [ "$MASTER" = "$short" ]
then
exit 10
fi
else
exit 11
fi
# Yes, we want to continue
$ECHO "C" >> $TMP
# Disallow all ypset requests
$ECHO "3" >> $TMP
# ... yes, this is correct
$ECHO "y" >> $TMP
# Use all of the NIS databases served by the NIS server
$ECHO "y" >> $TMP
# Start the NIS daemons now
$ECHO "y" >> $TMP
# Run the NIS setup utility
cat $TMP | $NISSETUP
# Done!
rm $TMP
exit 0